package tcm.com.gistone.api.restController;

import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import tcm.com.gistone.api.service.WordService;
import tcm.com.gistone.database.config.GetBySqlMapper;
import tcm.com.gistone.util.ClientUtil;
import tcm.com.gistone.util.EdatResult;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by wangfan on 2017/8/12.
 */
@RestController("apiSceTypeController")
@RequestMapping("api/sectype")
public class SecTypeController {


    @Autowired
    private GetBySqlMapper getBySqlMapper;

    /**
     * 获取段落类型列表
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "getAll", method = RequestMethod.POST)
    public EdatResult getAll(HttpServletRequest request, HttpServletResponse response) {
        try {
            ClientUtil.SetCharsetAndHeader(request, response);

            String sql = "select * from tb_sec_type";
            List<Map> result = getBySqlMapper.findRecords(sql);
            return EdatResult.ok(result);
        } catch (Exception e) {
            e.printStackTrace();
            return EdatResult.build(1, "fail");
        }
    }




}
